<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Set"%>
<%@page import="hamaster.jpbc.pbc.io.ID"%>
<%@page import="hamaster.jpbc.pbc.io.BinaryIDIOImpl"%>
<%@page import="hamaster.jpbc.pbc.io.IDIO"%>
<%@page import="hamaster.jpbc.sys.IBCSystem"%>
<%@page import="hamaster.jpbc.dao.IDKeyDAO"%>
<%@page import="hamaster.jpbc.IDKey"%>
<%@page import="hamaster.jpbc.User"%>
<%
User user = (User) session.getAttribute("user");
if (user == null) {
	response.sendError(404);
	return;
}
IDKeyDAO keyDAO = (IDKeyDAO) IBCSystem.getBean("idKeyDAO");
List<IDKey> keys = keyDAO.getAll(user);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/ibcid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/json.js"></script>
<script type="text/javascript" src="js/ibcid.js"></script>
<title>ID管理</title>
</head>
<body>
<div class="mainbd">
<% if (keys != null && keys.size() > 0) { %>
<div id="downloadkeys">
<form action="down.do">
<input type="hidden" name="action" value="download" />
<%
for (IDKey key : keys) {
	IDIO idio = new BinaryIDIOImpl(key.getKeyContent());
	ID id = idio.load();
%>
	<div class="idklink">
		<a class="fakelink" onclick="showIDKeyDetails(<%= key.getKeyId() %>)">
			<%= id.getPersonalParameter().getrIDString() %>
		</a>
	</div>
<% } %>
</form>
</div>
<% } %>
<div class="applyid">
<form action="id.do" method="post" name="form1" onsubmit="return checkApply()">
<input type="hidden" name="action" value="apply" />
	<div class="iditem">
		<span class="idlabel">电子邮件：</span>
		<span class="idinput">
			<input type="text" name="email" id="email" value="<%= user.getEmail() %>" />
		</span>
	</div>
	<div class="iditem">
		<span class="idlabel">确认密码：</span>
		<span class="idinput">
			<input type="password" name="password" id="password" />
		</span>
	</div>
	<div class="iditem">
		<span class="idlabel">时间信息：</span>
		<span class="idinput">
			<input name="date" type="checkbox" onclick="showTimeZoneSels()" />
			<select name="timezone" id="timezone" class="timezoneh">
				<option value="default">选择时区</option>
				<%
				Set<IBCSystem.IBCTimeZone> itzs = IBCSystem.getTimeZones();
				for (IBCSystem.IBCTimeZone itz : itzs) {
				%>
				<option value="<%= itz.getTzID() %>"><%= itz.getDisplayName() %></option>
				<% } %>
			</select>
		</span>
	</div>
	<div class="iditem">
		<span class="idsubmit">
			<input type="submit" name="apply" value="申请" />
		</span>
	</div>
</form>
</div>
</div>
</body>
</html>